#快速排序
def quick_sort(arr):
    def solve(arr, left, right):
        
        if left >= right:
            return arr
        key = arr[left]
        low = left
        high = right
        while left < right:
            while left < right and arr[right] >= key:
                right -= 1
            arr[left] = arr[right]
            while left < right and arr[left] <= key:
                left += 1
            arr[right] = arr[left]
        arr[right] = key
        solve(arr, low, left - 1)
        solve(arr, left+1, high)
        return arr
    return solve(arr, 0, len(arr)- 1)
print(quick_sort([5,5,5,2,3,8,1]))
